#pragma once

#include "GameObject.h"
#include "GameUtilities.h"
#include "Graph.h"
#include "mapNode.h"

static V2DI idx[4] =
{
	V2DI(0,1),
	V2DI(1,2),
	V2DI(2,3),
	V2DI(3,0),
};

class GameEnemy : public GameObject
{
private:
	float m_moveSpd;
	float m_viewW;
	float m_viewR;

	clkTriCone m_view;
	V2DF m_lineA[2], m_lineB[2];
	List<clkObject*>* m_objs;

	bool m_targetFound;
	GameObject* m_target;
	bool m_wandering;
	bool m_seeking;

	bool onNode(Vector2D<float> a_pos);

	
	//Astar* m_astar;//astar for everyone.

	Vector2D<float> m_wanderPos;

	TemplateVector<GraphNode<mapNode>*>* path;
	int m_currentPathIndex;


public:
	GameEnemy();
	~GameEnemy();

	void initEnemy(float a_moveSpd, float a_vWid, float a_vRad);
	void initTarget(GameObject* a_target);
	void initLine(List<clkObject*>* a_objs);

	void wander(); //wander around
	void seek(); //seek the player
	void seekPos(Vector2D<float> a_pos); //head towards position
	void ai(); //either seek or wander

	bool enemyUpdate();
	void nextNode();
	void draw();
	void drawPath();
	bool returningPath;
	void resetPath()
	{
		m_currentPathIndex = 0;
		returningPath = false;
	}
	TemplateVector<GraphNode<mapNode>*>* getPath(){return path;}
};
